#include<bits/stdc++.h>
using namespace std;

#define ll long long
int main()
{
    int n; cin >> n;
    vector<ll>a(n + 1),prea(n+1);
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        prea[i] = prea[i - 1] + a[i];
    }
    auto b = a;
    vector<ll>preb(n + 1);
    sort(b.begin()+1,b.end());//对b排序得到有序数组   
    for (int i = 1; i <= n; i++)preb[i] = preb[i - 1] + b[i];//求b数组的前缀和

    int t = 0;
    cin >> t;
    while (t--)
    {
        int op = 0, l, r; cin >> op >> l >> r;
        if (op == 1)
        {
            cout << prea[r] - prea[l - 1] << endl;//区间[l,r]之和
        }
        else
            cout << preb[r] - preb[l - 1] << endl;
    }
    return 0;
}


